import 'package:flutter/foundation.dart';
import 'package:shared_preferences/shared_preferences.dart';

class SettingsModel with ChangeNotifier {
  String _myString = '';

  String get myString => _myString;

  // 从SharedPreferences读取数据
  Future<void> loadMyString() async {
    final prefs = await SharedPreferences.getInstance();
    _myString = prefs.getString('myString') ?? '';
    notifyListeners();
  }

  // 保存数据到SharedPreferences
  Future<void> saveMyString(String value) async {
    final prefs = await SharedPreferences.getInstance();
    await prefs.setString('myString', value);
    _myString = value;
    notifyListeners();
  }
}
